
<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"  %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<style>
		form
		{
			height: 200px;
			width:320px;
			border-style:solid;
			border-width:1px; 
			margin:auto;
			margin-top:120px;
		}
		div
		{
			margin-left:68px;
			margin-top:20px;
		}
		a
		{
			position: absolute;
			left:656px;
			top:275px;
		}
	</style>
	<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
	</script>
</head>
	<body>
		<form action="${pageContext.request.contextPath }/user/login" method="post">
			<div>
			<label>身份:</label><br/>
			<select name="identity" style="width:143px">
				<option value="employee">员工</option>
				<option value="consumer" selected="selected">顾客</option>
			</select>
			<br/>
			<label>用户名</label><br/><input id="username" onblur="a()" type="text" name="username"/><label id="repeat"></label><br/>
			<label>密码</label><br/><input id="password" onblur="b()" type="password" name="password"/><label id="repeat2"></label><br/>
			<input type="button" value="登录" onclick="check()"/>
			</div>
		</form>
		<a href="${pageContext.request.contextPath }/user/signupfirst"><button>注册</button></a>
		<c:if test="${signup=='yes'}" >
			<script>
				$(document).ready(function(){
					  alert("注册成功");
					})
			</script>
		</c:if>
		<c:if test="${login}" >
			<script>
				$(document).ready(function(){
					  alert("用户名密码错误");
					})
			</script>
		</c:if>
	<script type="text/javascript">
	function b()
	{
		if($.trim($("#password").val())=="")
		{
			$("#repeat2").html("<span style='color:red'>请输入密码</span>");
			return;
		}
		else
		{
			$("#repeat2").empty();
		}
	}
	function a()
	{
		if($.trim($("#username").val())=="")
		{
			$("#repeat").html("<span style='color:red'>请输入用户名</span>");
			return;
		}
		else
		{
			$("#repeat").empty();
		}
	}
	 function check() {

	        if($.trim($("#username").val())=="") {
	               alert("请输入用户帐号!");
	               return false;
	          }
	      	if($.trim($("#password").val())==""){
	               alert("请输入登录密码!");
	               return false;
	        }
	      $("form")[0].submit();
		}
	
	</script>
		
	</body>
</html>